package com.oocl.zero.task0710.property.parse.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.oocl.zero.task0710.property.parse.Parser;

public class ParserImpl implements Parser {

	public static final String BLANK_REGEX = "\\s+";
	
	private static Map<Integer,String> map = new HashMap<Integer,String>(); 
	
	public void doParse(String input) {
		Pattern p = Pattern.compile(ParserImpl.BLANK_REGEX);
		Matcher m = p.matcher(input);
		int idx=0;
		int from=0;
		int to;
		String content;
		while (m.find()) {
			to = m.start();

			++idx;
			content = input.substring(from, to);
			map.put(idx, content);

			from = m.end();
		}
		++idx;
		content = input.substring(from);
		map.put(idx, content);
	}
	
	public Map<Integer, String> getDataMap() {
		return map;
	}
	
	public static void setMap(Map<Integer, String> map) {
		ParserImpl.map = map;
	}
}
